package com.lyy.seckill.dao;

import com.lyy.seckill.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserDao {

    @Select("select * from sk_user where id = #{id}")
    public User getById(@Param("id") long id);

    @Update("update sk_user set password = #{password} where id = #{id}")
    public void update(User toBeUpdate);

    @Insert("insert into sk_user (id, nickname, password, salt, head, register_date, last_login_date, login_count) VALUES (" +
            "#{id},#{nickname},#{password}, #{salt}, #{head}, #{registerDate}, #{lastLoginDate}, #{loginCount})")
    public void insert(User toInsert);
}
